package com.scorpio.user.feign;

import com.scorpio.user.api.entity.UserVo;
import com.scorpio.user.api.feign.IUser2Client;
import com.scorpio.user.service.IUserService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author sdaduanbilei
 */
@RestController
@AllArgsConstructor
public class UserClientImpl implements IUser2Client {


    @Autowired
    private IUserService iUserService;

    @Override
    @GetMapping(LIST)
    public List<UserVo> getAll() {
        return iUserService.getAll().stream().map(it -> new UserVo(it.getName(), it.getAge())).collect(Collectors.toList());
    }
}
